from django.shortcuts import render,redirect,HttpResponse
from django import forms
from app01 import models


# Create your views here.
class Regform(forms.Form):
    mail = forms.CharField(
        label='邮箱',
        required=False,
        error_messages={
        }
    )
    phone = forms.CharField(
        label='手机',
        error_messages={
            'required': '请输入手机号'
        }
    )
    username = forms.CharField(
        label='登录用户',
        min_length=6,
        error_messages={
            'min_length': '输入长度不能少于6位'
        }
    )
    name = forms.CharField(
        label='显示用户'
    )
    password = forms.CharField(
        label='密码',
        widget=forms.PasswordInput,
    )
    re_password = forms.CharField(
        label='确认密码',
        widget=forms.PasswordInput,
    )


def register(request):
    form_obj = Regform()
    if request.method == 'POST':
        form_obj = Regform(request.POST)
        if form_obj.is_valid():
            return HttpResponse('注册成功')
    return render(request, 'register.html', {'form_obj': form_obj})
